package com.cl.erp_2301.controller;

import com.cl.erp_2301.dto.DataDTO;
import com.cl.erp_2301.dto.MenuDTO;
import com.cl.erp_2301.dto.StoreDTO;
import com.cl.erp_2301.entity.Store;
import com.cl.erp_2301.Service.StoreService;
import com.cl.erp_2301.util.Result;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.List;

@RestController
@RequestMapping("/v2")
public class StoreController {
    @Resource
    private StoreService storeService;
    @GetMapping("/store/listByPage")
    public Result listByPage(int page,int rows){
        Page<Object> page1=PageHelper.startPage(page,rows);
        List<StoreDTO> storeDTOList=storeService.listByPage();
        DataDTO dataDTO=new DataDTO<>();
        dataDTO.setTotal(dataDTO.getTotal());
        dataDTO.setRows(storeDTOList);
        return Result.ok(dataDTO);
    }
    @ResponseBody
    @RequestMapping("/store/add")
    public Result add(@RequestParam("name") String name,@RequestParam("empuuid") Integer empuuid){
        StoreDTO storeDTO=new StoreDTO();
        storeDTO.setName(name);
        storeDTO.setEmpuuid(empuuid);
        storeService.add(storeDTO);
        return Result.ok();
    }


}
